package com.cskaoyan.service.statistics;

import com.cskaoyan.bean.statistics.BaseStatisticsVO;
import com.cskaoyan.bean.statistics.OrderStatisticsData;
import com.cskaoyan.bean.statistics.ProductStatisticsData;
import com.cskaoyan.bean.statistics.UserStatisticsData;
import com.cskaoyan.mapper.statistics.StatisticsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description:数据统计实现类()
 * @author: Jason 805636901@qq.com
 * @create: 2021-10-21-10:20 AM
 */
@Service
public class StatisticsServiceImpl implements StatisticsService{

    @Autowired
    StatisticsMapper statisticsMapper;
    //在这里把数据封装好
    @Override
    public BaseStatisticsVO getUserData() {
        BaseStatisticsVO baseStatisticsVO = new BaseStatisticsVO();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("users");
        baseStatisticsVO.setColumns(columns);

        List<UserStatisticsData> rows = statisticsMapper.selectUserDataList();
        baseStatisticsVO.setRows(rows);
        return baseStatisticsVO;
    }

    @Override
    public BaseStatisticsVO getOrderData() {
        BaseStatisticsVO baseStatisticsVO = new BaseStatisticsVO();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("customers");
        columns.add("amount");
        columns.add("pcr");
        baseStatisticsVO.setColumns(columns);

        List<OrderStatisticsData> rows = statisticsMapper.selectOrderDataList();
        baseStatisticsVO.setRows(rows);
        return baseStatisticsVO;
    }

    @Override
    public BaseStatisticsVO getGoodsData() {
        BaseStatisticsVO baseStatisticsVO = new BaseStatisticsVO();
        List<String> columns = new ArrayList<>();
        columns.add("day");
        columns.add("orders");
        columns.add("products");
        columns.add("amount");
        baseStatisticsVO.setColumns(columns);

        List<ProductStatisticsData> rows = statisticsMapper.selectGoodsDataList();
        baseStatisticsVO.setRows(rows);
        return baseStatisticsVO;
    }
}
